import { Inject, Controller, Post, Body, sleep } from '@midwayjs/core';
import { Context } from '@midwayjs/koa';
import { ILoginOptions } from '../interface';
import { LoginService } from '../service/login.service';

@Controller('/api')
export class LoginController {
  @Inject()
  ctx: Context;

  @Inject()
  loginService: LoginService;

  @Post('/user/v1/login')
  async login(@Body() user: ILoginOptions) {
    await sleep(4000);
    const result = await this.loginService.login(user);
    return result;
  }
}
